home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / Telephone Manager / Stiletto Sources / ModuleSources / DNLookupByName.c < prev    next >
Encoding:
Text File  |  1995-07-05  |  2.9 KB  |  109 lines  |  [TEXT/MPS ]

  1. /************************************************************************************************/
  2. /*                                                                                                */
  3. /*    Module Name:    DNLookupByName                                                                */
  4. /*                                                                                                */
  5. /*    File Name:        DNLookupByName.c                                                            */
  6. /*                                                                                                */
  7. /*    © Apple Computer, Inc. 1991-1995                                                            */
  8. /*    All Rights Reserved                                                                            */
  9. /*                                                                                                */
  10. /*    Revision History:                                                                            */
  11. /*                                                                                                */
  12. /*        Date        Who                    Modification                                            */
  13. /*                                                                                                */
  14. /*        1991-07-16    Chris Halim            Original version                                        */
  15. /*        1995-06-26    Jaakko Railo        Version 2.0                                                */
  16. /*                                                                                                */
  17. /************************************************************************************************/
  18.  
  19. /****************************************** DESCRIPTION ******************************************
  20.  
  21. This module calls TELDNLookupByName to see if it can find a valid DN.
  22.  
  23. *************************************************************************************************/
  24.  
  25. /******************************************** HEADERS *******************************************/
  26.  
  27. //#include "Strings.h"
  28.  
  29. #include "TestModule.h"
  30.  
  31. /****************************************** DEFINITIONS *****************************************/
  32.  
  33. #define    rDNNameDLOG            10000
  34. #define    kDNName                3
  35.  
  36. /****************************************** PROTOTYPES ******************************************/
  37.  
  38. short    GetDNName (Str255 dnName);
  39. void     DoTest (CHRSPtr paramPtr);
  40.  
  41. /************************************************************************************************/
  42. /************************************************************************************************/
  43.  
  44.  
  45. pascal short TestModule (CHRSPtr paramPtr)
  46. {
  47.     short    returnValue = noErr;
  48.     
  49.     if (paramPtr->version <= kTestModuleVersion) {
  50.         
  51.         DoTest (paramPtr);
  52.         
  53.     }
  54.     else
  55.         returnValue = kWrongVersion;
  56.         
  57.     return (returnValue);
  58. }
  59.  
  60.  
  61. short    GetDNName (Str255 dnName)
  62. {
  63.     short        itemKind;
  64.     Handle        itemHand;
  65.     Rect        itemRect;
  66.     short        itemHit;
  67.     DialogPtr    theDialog;
  68.     
  69.     if ((theDialog = GetNewDialog (rDNNameDLOG, nil, (WindowPtr)(-1L))) != nil) {
  70.         ShowWindow (theDialog);
  71.         
  72.         ModalDialog (nil, &itemHit);
  73.         
  74.         if (itemHit == ok) {
  75.             GetDItem (theDialog, kDNName, &itemKind, &itemHand, &itemRect);
  76.             GetIText (itemHand, dnName);
  77.         }
  78.         
  79.         DisposeDialog (theDialog);
  80.     }
  81.     else
  82.         itemHit = -1;
  83.     
  84.     return (itemHit);
  85. }
  86.  
  87.  
  88. void DoTest (CHRSPtr paramPtr)
  89. {
  90.     TELHandle        termHand = GetCurrentTELHandle (paramPtr);
  91.     TELDNHandle        dnHand;
  92.     Str255            dnName;
  93.     short            itemHit;
  94.     OSErr            errCode;
  95.     
  96.     if ((itemHit = GetDNName (dnName)) == ok) {
  97.         
  98.         if ((errCode = TELDNLookupByName (termHand, dnName, &dnHand)) == noErr)
  99.             Print (paramPtr, "'%*.*s' found, dnHand = %08x", dnName[0], dnName[0], &dnName[1], dnHand);
  100.         else
  101.             Print (paramPtr, "### Can't find '%*.*s', errCode = %d", dnName[0], dnName[0], &dnName[1], errCode);
  102.     }
  103.     else
  104.         if (itemHit == -1)
  105.             Print (paramPtr, "### Unable to get a DLOG resource");
  106. }
  107.  
  108.  
  109.